<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
     <input type="text" id="text">
     <input type="button" value="查询" id="btn">
     <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
     <script type="text/javascript">
         $(function(){
             $("#btn").click(function(){

                 $.ajax({
                    url:"data/student",
                     type:"get",
                     async:false,
                     success:function(data){
                         var text=$("#text").val();
                         var obj=JSON.parse(data);
                         for(var i=0;i<obj.length;i++){
                             if(obj[i].name==text){
                                document.write(obj[i].name+obj[i].age+obj[i].position);
                             }else{
                                   //如果循环的次数是最后一次才打印
                                   if(i==obj.length-1){
                                       document.write("查询的人物不存在");
                                   }

                             }
                         }
                     }

                 });


             });


         });




     </script>
</body>
</html>